package com.laotou99.wmsjjj.wmsjjj.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.laotou99.wmsjjj.wmsjjj.bean.vo.LOCVO;
import com.laotou99.wmsjjj.wmsjjj.service.LOCService;

/**
 * @category 库位控制路径
 * */
@Controller
@RequestMapping("/loc")
public class LOCController {

	@Autowired
	LOCService locService;
	
	//保存库位
	@RequestMapping("/saveLOC")
	@ResponseBody
	public String saveLOC(LOCVO vo) {
		if(vo.getLocNum()==null || 
			vo.getLocNum().equals("")) 
		{
			return "ERROR";
		}
		if(locService.saveLOC(vo)) {
			return "ERROR";
		}
		return "OK";
	}
	
	//修改库位
	@RequestMapping("/updateLOC")
	@ResponseBody
	public String updateLOC(LOCVO vo) {
		if(vo.getId()==0) {
			return "ERROR";
		}
		if(locService.updateLOC(vo)) {
			return "ERROR";
		}
		return "OK";
	}
	
	//删除库位
	@RequestMapping("/delLOC")
	@ResponseBody
	public String delLOC(long id1) {
		if(id1==0) {
			return "ERROR";
		}
		if(locService.delLOC(id1)) {
			return "ERROR";
		}
		return "OK"; 
	}
	
	//冻结库位
	@RequestMapping("/holdLOC")
	@ResponseBody
	public String holdLOC(long id1) {
		if(id1==0) {
			return "ERROR";
		}
		if(locService.holdLOC(id1)) {
			return "ERROR";
		}
		return "OK"; 
	}
	
	//解冻库位
	@RequestMapping("/unHoldLOC")
	@ResponseBody
	public String unHoldLOC(long id1) {
		if(id1==0) {
			return "ERROR";
		}
		if(locService.unHoldLOC(id1)) {
			return "ERROR";
		}
		return "OK"; 
	}
	
	//显示所有的库位
	@RequestMapping("/showAllLoc")
	@ResponseBody
	public String showAllLoc() {
		String strJson = locService.showAllLoc();
		return strJson;
	}
}
